package com.icebartech.timebank.starter;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * Created by dengyaming on 25/09/2017.
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
              .host("timebank.icebartech.com")
              .apiInfo(apiInfo())
              .select()
              .apis(RequestHandlerSelectors.basePackage("com.icebartech"))
              .paths(PathSelectors.any())
              .build();
    }
    
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
              .title("时间银行 API 接口文档")
              .description("时间银行 API 接口文档")
              .termsOfServiceUrl("http://localhost:60830/api")
              .version("1.0")
              .build();
    }
}